package com.bjpowernode.task;

import com.bjpowernode.api.serivce.IncomeService;
import com.bjpowernode.util.HttpClientUtils;
import org.apache.dubbo.common.logger.log4j2.Log4j2Logger;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.log4j.spi.LoggingEvent;
import org.apache.logging.log4j.spi.ExtendedLoggerWrapper;
import org.slf4j.Logger;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author 麦翔盛
 * @ClassName: TaskManage
 * @Package: com.bjpowernode.task
 * @description: 定时任务
 * @date 2022/5/28 23:45
 */
@Component("taskManager")
public class TaskManager {
    @DubboReference(interfaceClass = IncomeService.class,version = "1.0")
    private IncomeService incomeService;

    //@Scheduled(cron = "0 0 1 * * ?")
    public void generateIncomePlan(){
        System.out.println("实行了收益计划生成远程调用。。。" + new Date());
        incomeService.generateIncomePlan();
    }

    //@Scheduled(cron = "0 0 2 * * ?")
    public void generateIncomeBack(){
        System.out.println("实行了收益返还远程调用。。。" + new Date());
        incomeService.generateIncomePlan();
    }


    /**
     * 调用支付服务
     */
    @Scheduled(cron = "0 0/20 * * * ?")
    public void invokePayKuaiQianQuery(){
        System.out.println("执行了支付服务远程调用。。。" + new Date());
        try {
            HttpClientUtils.doGet("http://localhost:9000/pay/recharge/pay/kq/query");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
